﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace DataReceiver
{
    public static class Helper
    {
        public static bool TryParse(string s, out IpEndpoint ipEndpoint)
        {
            ipEndpoint = null;
            if (string.IsNullOrEmpty(s))
            {
                return false;
            }

            try
            {
                var strings = s.Split(':');
                var ip = IPAddress.Parse(strings[0]);
                var port = int.Parse(strings[1]);
                ipEndpoint = new IpEndpoint() { IpAddress = strings[0], Port = port };
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            
        }
    }
}
